import random

target=random.randint(0,100)
count=1
while True:
    try:
        guess=int(input("猜一个0到100的整数 "))
        if guess>target:
            print("大了")
        elif guess<target:
            print("小了")
        else:
            print("猜对了，本轮幸运数字就是{},一共尝试了{}次".format(target,count))
        count+=1
    except:
        print('输入有误')
        break
